﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Tosi
{
    class StatTable
    {
        private int CarNr;
        private int StreetNr;
        private int JunctionNr;
        private int NrOfMoves;

        // STAT
        
        public double[,] StreetLoad;
        public int[,] WaitingTimePerLight;
        public int[,] WaitingCarsPerLight;
        public double[,] JunctionCongestion;
       // public double[,] JunctionLoad;
        //public int[,] CarSpeed;
        //public int[,] LightState;
        // public int[,] CarsOnStreet;
        //public int[,] CarsInJunction;

        // INTERVAL STAT
       
        public int[] SumWaitingTimePerStreet;
        public double[] AvgWaitingCarsPerStreet;
        public double[] AvgStreetLoad;
        public double[] IntJunctionCongestion;
        public double[] AvgWaitingTimePerJunction;
        public double[] AvgWaitingCarsPerJunction;
        //public double[] IntAverageCarSpeed;
        //public int[,] IntSumLightState;
        //public int[] IntSumCarsOnJunction;
        //public double[] IntJunctionLoadPerCapacity;   //a csomoponthoz tartozo elek zsufoltsaga a kapacitashoz viszonyitva
        //public double[] IntJunctionLoadPerCarNr;   
        // public double[] AvgWaitingTime;
        // public double[] AvgJunctionLoad;
        

        public StatTable()
        {
            CarNr = Var.CarNr;
            StreetNr = Var.STREETS.Length;
            JunctionNr = Var.JUNCTIONS.Length;
            NrOfMoves = Var.Iterations;

            StreetLoad = new double[NrOfMoves, StreetNr];
            WaitingCarsPerLight = new int[NrOfMoves, StreetNr];          
            WaitingTimePerLight = new int[NrOfMoves,StreetNr];         
            JunctionCongestion = new double[NrOfMoves, JunctionNr];
            //CarSpeed = new int[NrOfMoves, CarNr];
            //LightState = new int[NrOfMoves, StreetNr];
            //CarsOnStreet = new int[NrOfMoves, StreetNr];
            //CarsInJunction = new int[NrOfMoves, JunctionNr];
            // JunctionLoad = new double[NrOfMoves, JunctionNr];
           
      
            
            IntJunctionCongestion = new double[JunctionNr];
            SumWaitingTimePerStreet = new int[StreetNr];
            AvgStreetLoad = new double[StreetNr];
            AvgWaitingCarsPerStreet = new double[StreetNr];
            AvgWaitingTimePerJunction = new double[JunctionNr];
            AvgWaitingCarsPerJunction = new double[JunctionNr];
            //IntAverageCarSpeed = new double[CarNr];
            //IntSumLightState = new int[StreetNr, 2];      // o1 = piros szam, o2 zold szam
            //IntSumCarsOnJunction = new int [JunctionNr];
            //IntJunctionLoadPerCapacity = new double[JunctionNr];
            //IntJunctionLoadPerCarNr = new double[JunctionNr];
            //AvgWaitingTime = new double[StreetNr];
            //   AvgJunctionLoad = new double[JunctionNr];
            init();
        }

        public void init()                  // lenullazza a tablakat
        {
            
            initStreetLoad();
            initJunctionCongestion();
            initWaitingTimePerLight();
            initWaitingCars();
            //initWaitingCarsPerJunction();
            //initWaitingTimePerJunction();
            //initCarSpeed();
            //initLightState();
            //initCarsOnStreet();
            //initCarsInJunction();
            // initJunctionLoad();

            
            initIntJunctionCongestion();
            initSumWaitingTime();
            initAvgWaitingTime();
            initAvgStreetLoad();
            initAvgWaitingTimePerJunction();
            initAvgWaitingCarsPerJunction();
            //initIntAverageCarSpeed();
            //initIntSumLightState();
            //initIntSumCarsOnJunction();
            //initIntJunctionLoadPerCapacity();
            //initIntJunctionLoadPerCarNr();
        }
        
        private void initAvgWaitingTimePerJunction()
        {
            for (int i = 0; i < JunctionNr; i++)
                AvgWaitingTimePerJunction[i] = 0;
        }
        private void initAvgWaitingCarsPerJunction()
        {
            for (int i = 0; i < JunctionNr; i++)
                AvgWaitingCarsPerJunction[i] = 0;
        }
        
        private void initStreetLoad()
        {
            for (int i = 0; i < NrOfMoves; i++)
                for(int j = 0; j < StreetNr; j++)
                   StreetLoad[i,j] = 0;
            
        }
       
        private void initJunctionCongestion()
        {
            for (int i = 0; i < NrOfMoves; i++)
                for(int j = 0; j < JunctionNr; j++)
                   JunctionCongestion[i,j] = 0;

        }
        private void initWaitingTimePerLight()
        {
            for (int i = 0; i < NrOfMoves; i++)
                for(int j = 0; j < StreetNr; j++)
                   WaitingTimePerLight[i,j] = 0;

        }
        private void initWaitingCars()
        {
            for (int i = 0; i < NrOfMoves; i++)
                for (int j = 0; j < StreetNr; j++)
                    WaitingCarsPerLight[i, j] = 0;
        }
        
        private void initIntJunctionCongestion()
        {
            for (int i = 0; i < JunctionNr; i++)
                IntJunctionCongestion[i] = 0;
        }
       
        private void initSumWaitingTime()
        {
            for (int i = 0; i < StreetNr; i++)
                SumWaitingTimePerStreet[i] = 0;
        }
        private void initAvgWaitingTime()
        {
            for (int i = 0; i < StreetNr; i++)
                AvgWaitingCarsPerStreet[i] = 0;
        }
        private void initAvgStreetLoad()
        {
            for (int i = 0; i < JunctionNr; i++)
                AvgStreetLoad[i] = 0;
        }

        //private void initWaitingCarsPerJunction()
        //{
        //    for (int i = 0; i < NrOfMoves; i++)
        //        for (int j = 0; j < JunctionNr; j++)
        //            WaitingCarsPerJunction[i, j] = 0;
        //}
        //private void initWaitingTimePerJunction()
        //{
        //    for (int i = 0; i < NrOfMoves; i++)
        //        for (int j = 0; j < JunctionNr; j++)
        //            WaitingTimePerJunction[i, j] = 0;
        //}

        /*private void initCarSpeed()
        {
            for (int i = 0; i < NrOfMoves; i++)
                for(int j = 0; j < CarNr; j++)
                    CarSpeed[i,j] = 0;
        }
        private void initLightState()
        {
            for (int i = 0; i < NrOfMoves; i++)
                for(int j = 0; j < StreetNr; j++)
                    LightState[i,j] = 0;
        }*/
        /*private void initCarsOnStreet()
        {
            for (int i = 0; i < NrOfMoves; i++)
                for(int j = 0; j < StreetNr; j++)
                   CarsOnStreet[i,j] = 0;
        }*/
        /*private void initCarsInJunction()
       {
           for (int i = 0; i < NrOfMoves; i++)
               for(int j = 0; j < JunctionNr; j++)
                  CarsInJunction[i,j] = 0;

       }*/
        //private void initJunctionLoad()
        //{
        //    for (int i = 0; i < NrOfMoves; i++)
        //        for (int j = 0; j < JunctionNr; j++)
        //            JunctionLoad[i, j] = 0;
        //}
        /*private void initIntAverageCarSpeed()
        {
            for (int i = 0; i < CarNr; i++)
                IntAverageCarSpeed[i] = 0;
        }
        private void initIntSumLightState()
        {
            for (int i = 0; i < StreetNr; i++)
            {
                IntSumLightState[i,0] = 0;
                IntSumLightState[i,1] = 0;
            }
        }
        private void initIntSumCarsOnJunction()
        {
            for (int i = 0; i < JunctionNr; i++)
                IntSumCarsOnJunction[i] = 0;
        }*/
        /*private void initIntJunctionLoadPerCapacity()
       {
           for (int i = 0; i < JunctionNr; i++)
               IntJunctionLoadPerCapacity[i] = 0;
       }
       private void initIntJunctionLoadPerCarNr()
       {
           for (int i = 0; i < JunctionNr; i++)
               IntJunctionLoadPerCapacity[i] = 0;
       }*/
    }

}

